//
//  MASConstraintMaker+SS.m
//  Interesting
//
//  Created by point on 2018/2/8.
//  Copyright © 2018年 whiteboard. All rights reserved.
//

#import "MASConstraintMaker+SS.h"
#import <objc/message.h>

#define ScreenWidth [UIScreen mainScreen].bounds.size.width
#define FIT_LENGTH(x)  x * ScreenWidth / 375.f








@implementation MASConstraintMaker (SS)

static char *sssizeMakekey = "sssizeMake";

- (void)ssizeMake:(CGSize)size {
     self.size.mas_equalTo(CGSizeMake(FIT_LENGTH(size.width), FIT_LENGTH(size.height)));
}

- (CGSize)sSize {
    NSValue *value = objc_getAssociatedObject(self, @"sSize");
    if(value) {
        CGSize rect;
        [value getValue:&rect];
        return rect;
    }else {
        return CGSizeZero;
    }
}

- (void)setSSize:(CGSize)sSize {
     self.size.mas_equalTo(CGSizeMake(FIT_LENGTH(sSize.width), FIT_LENGTH(sSize.height)));
    NSValue *value = [NSValue value:&sSize withObjCType:@encode(CGSize)];
    objc_setAssociatedObject(self, @"sSize", value, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
}

- (MASConstraintMaker *(^)(CGSize ))ssSize {
    return ^(CGSize ssSize) {
       self.size.mas_equalTo(CGSizeMake(FIT_LENGTH(ssSize.width), FIT_LENGTH(ssSize.height)));
        return self;
    };
}

- (MASConstraintMaker *(^)(id ))mas_sequalTo {
    return ^(id mas_sequalTo) {
       // self.size = mas_sequalTo;
        [self setValue:mas_sequalTo forKey:@"size"];
        return self;
    };
}


//
//-(void)setPushFrame:(CGRect)pushFrame{
//    NSValue *value = [NSValue value:&pushFrame withObjCType:@encode(CGRect)];
//    //因为已经把 pushFrame 作为对象进行存储 所以也应该将存储的策略模式设置为对象的策略模式
//    objc_setAssociatedObject(self, @"pushFrame", value, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
//}
//
//-(CGRect)pushFrame{
//    NSValue *value = objc_getAssociatedObject(self, @"pushFrame");
//    if(value) {
//        CGRect rect;
//        [value getValue:&rect];
//        return rect;
//    }else {
//        return CGRectZero;
//    }
//}



//- (void)setSssizeMake:(CGSize)sssizeMake {
//
//}
//
//- (CGSize)sssizeMake {
//     return objc_getAssociatedObject(self, sssizeMakekey);
//}

//- (void)setSssizeMake:(CGSize )sssizeMake {
//        objc_setAssociatedObject(self, sssizeMakekey, sssizeMake, OBJC_ASSOCIATION_ASSIGN);
//}
//
//- (CGSize )sssizeMake {
//    return objc_getAssociatedObject(self, sssizeMakekey);
//
//}

@end
